package com.xinqi.modules.discuss.discuss.factory;

import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.discuss.discuss.client.CourseDiscussClient;
import com.xinqi.modules.discuss.discuss.dto.req.CourseDiscussCreateDTO;
import com.xinqi.modules.discuss.discuss.dto.req.CourseDiscussQueryDTO;
import com.xinqi.modules.discuss.discuss.dto.req.CourseDiscussUpdateDTO;
import com.xinqi.modules.discuss.discuss.dto.rsp.CourseDiscussResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 课程讨论主表降级处理
 *
 * @author: wenjie
 * @date: 2023/10/30
 */
@Slf4j
@Component
public class CourseDiscussFallbackFactory implements FallbackFactory<CourseDiscussClient> {

    @Override
    public CourseDiscussClient create(Throwable throwable) {
        log.error("日志服务调用失败:{}", throwable.getMessage());
        return new CourseDiscussClient() {

            @Override
            public R<CourseDiscussResultDTO> findById(Long id) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }


            @Override
            public R<Boolean> update(Long id, CourseDiscussUpdateDTO dto) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }


            @Override
            public R<Void> participate(Long classId, Long contentId, Long userId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<Boolean> classAddMembers(Long classId, Long userId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }
        };
    }
}
